package com.itheima.service;

import com.itheima.dao.UserMapper;
import com.itheima.pojo.User;
import com.itheima.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImp implements UserService {

    /**
     * 登入成功，将用户的信息，用户对应的角色信息，角色对应的权限信息都获取出来
     *
     * @param username 登录名
     * @param password 登录密码
     * @return
     */
    @Override
    public User login(String username, String password) {
        //获取会话对象
        SqlSession session = SqlSessionUtil.getSession();
        //用户的dao层代码，完成登录
        UserMapper mapper = session.getMapper(UserMapper.class);
        User user = mapper.findUserByUserNameAndPassword(username, password);
        //释放资源
        session.close();
        //返回数据
        return user;
    }
}
